全部学科
NodeJS全栈
nodejs
Python全栈
python
📅 2026-05-23 8 分钟 ✍️ juanwangdev

GitHub Actions 配置

GitHub Actions 自动化 Maven 构建。

工作流文件

YAML
# .github/workflows/maven.yml
name: Maven Build
on: [push, pull_request]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-java@v3
        with:
          java-version: '17'
          distribution: 'temurin'
      - run: mvn clean install

缓存配置

YAML
- uses: actions/cache@v3
  with:
    path: ~/.m2/repository
    key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}

要点总结

  • setup-java 配置 Java 环境
  • actions/cache 缓存 Maven 仓库
  • mvn 命令执行构建
想在手机上练习这篇文章的配套题目?
使用微信卷王开发者小程序,打开首页顶部扫码功能识别二维码
← 上一篇 Jenkins 流水线集成
下一篇 → GitLab CI 集成
扫码体验小程序
加载中
想在手机上刷题学习?
使用微信卷王开发者小程序,打开首页顶部扫码功能识别二维码